package com.abyss.mr.sort;

import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class SortReducer extends Reducer<IntWritable, NullWritable, LongWritable, IntWritable> {
    LongWritable count = new LongWritable(0);

    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        for (NullWritable value : values) { //遍历value同时，key也会随着遍历。
            count.set(count.get() + 1);
            context.write(count, key);
        }
    }
}
